﻿using System.Linq;
using AMAP.ServiceInterfaces.Common;
using AMAP.Domain;
using System.Data.Entity;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity.Validation;
using System.Diagnostics;

namespace AMAP.ServiceClasses.Common
{
    public abstract class BaseDatabaseService : IDatabaseService
    {
        protected AMAPModelContainer dataContext;

        protected virtual IDatabaseFactory DatabaseFactory
        {
            get; set;
        }

        protected BaseDatabaseService(IDatabaseFactory databaseFactory)
        {
            DatabaseFactory = databaseFactory;
            dataContext = DatabaseFactory.Get();
        }

        public virtual void Dispose()
        {
            DatabaseFactory.Dispose();
        }

        public virtual void Save()
        {
            dataContext.SaveChanges();
        }
    }
}
